/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const BaseJsonAdapter = require('../base/BaseJsonAdapter');
const iconv = require("iconv-lite");
const vm = require('vm');
const request = require('request-promise');
const cheerio = require('cheerio');
const logger = require('../../conf/logger');
const querystring = require("querystring")
const urlencode = require("urlencode")

/**
 */
module.exports = class Alibabacloud extends BaseJsonAdapter{

    async reqJson(){
        const body = await this.doRequest();
        let decodeBody = iconv.decode(body, this.encoding).toString();
        let startStr = 'window.pressPageData["tab0"]=';
        let start = decodeBody.indexOf(startStr) + startStr.length;
        let stop = decodeBody.indexOf('window.pressPageData["tab1"]=');
        decodeBody = decodeBody.substring(start, stop).trim().replace(/;$/, "");
        let data = JSON.parse(decodeBody);
		return {
		    data: data
        }
	}
}


